package com.itstyle.seckill.common.aop;

import com.itstyle.seckill.common.entity.Result;
import com.itstyle.seckill.common.exception.RrException;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Configuration
@ControllerAdvice
public class ExceptionAdapterController {

    @ExceptionHandler(RrException.class)
    @ResponseBody
    public Result rrExceptionAdvice(RrException e){
        e.printStackTrace();
        return Result.error("小同志，你访问的太频繁了");
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exceptionAdvice(Exception e){
        e.printStackTrace();
        return Result.error();
    }
}
